from queue import Queue
from threading import Thread
from PoseStream import getPoseStream
from MatchGestrue import matchGesture
from ParseGesture import parseGestures
from ReadConfig import readConfig
import sys

multi_hand_fsms=[]
args=list(sys.argv[1:])
if not args:
    args.append('config.ini')
for i, config in enumerate(args):
    gestrues=readConfig(config)
    print('G[{}]:\t{}'.format(config,gestrues))
    fsm_list, fail_list=parseGestures(gestrues)
    print('F[{}]:\t{}'.format(config,fsm_list))
    print('E[{}]:\t{}'.format(config,fail_list))
    multi_hand_fsms.append(fsm_list)

# 用来表示终止的特殊对象
_sentinel = object()

poses_q = Queue()
t1 = Thread(target=matchGesture, args=(poses_q, multi_hand_fsms, _sentinel))
t2 = Thread(target=getPoseStream, args=(poses_q, _sentinel))
t1.start()
t2.start()